function main() {
    //新增页面
    if ($this.pageType == 'add') {
        if ($this.$store.state.user.tabs[$this.$store.state.user.tabs.length - 1]) {
            let applicationdata = $this.$store.state.user.tabs[$this.$store.state.user.tabs.length - 1].applicationdata;
            if (applicationdata !== undefined && applicationdata !== "") {
                $this.model["selectStr_1690186702521_3m6iA"] = applicationdata[0].项目编号;//项目编号
                //$this.model["input_1761620061717_he6DO"] = applicationdata[0].项目编号;//选择项目立项 - 项目编号
                $this.model["input_1690186769700_NQIMN"] = applicationdata[0].项目名称;//项目名称
                $this.model["table_1761621684298_7OBB8"] = [];//表体

                //每条立项单
                for (let i = 0; i < applicationdata.length; i++) {
                    let url = $this.$util.getAPI_URL();
                    let formData = new FormData();
                    formData.append("id", applicationdata[i]["bill_id"]);
                    formData.append("whId", "df3e3289f0ad82cf6bfaedaad46201c3");
                    formData.append("str_name", "uploadFile_1688609943921_2JWsA"); //项目立项-技术交接单
                    formData.append("score_str_name", "uploadFile_1709713440888_3j89u"); //项目状态变更-技术交接单
                    formData.append("billId", $this.model.bill_id); //项目状态变更-billId
                    $this.$http.post("/formsBusiness/shishilixiangbyId/", formData).then((res) => {
                        if (res.data.code === 280) {
                            let data = res.data.data;
                            console.log("data = ",data);
                            //项目状态变更 = 项目立项 【数据赋值逻辑】
                            //$this.model.input_1711507868739_utRet = data[0]["bill_id"] 子 = 父；平级的bill_id不用赋值

                            //去掉首位空格+空格分割
                            let tempArr = data[0]["select_1761305206653_XuW8g"];
                            // 1. 去掉首尾空格（保险）
                            let rawStr = tempArr.trim();
                            // 2. 解析成数组
                            let idArr = JSON.parse(rawStr);   // 现在才是真正意义上的数组
                            console.log("设备数组 = ",idArr);

                            // 3. 循环 + switch 映射
                            let tempSet = new Set();
                            for (let i = 0; i < idArr.length; i++) {
                                let id   = idArr[i];
                                let name = '';          // 先置空，防止穿透污染
                                switch (id) {
                                    case '47a2c5b1ea1a3f14c29e96c65579a7aa': name = '高压变频器'; break;
                                    case '145adcede8748ba49f7eae7ae44868ef': name = '有源滤波器'; break;
                                    case 'f2f4e74e99f7d5714d5c3c4d8187bde8': name = '固态软启动'; break;
                                    case 'bf958dd85562bf779b26a50aa3877329': name = '维修服务';   break;
                                    case 'c13556e04b14c190bc51ac0a0b5e8fb0': name = '技术服务';   break;
                                    case '9cf8331436d1f29410c2351ea640da3b': name = '工程型变频器'; break;
                                    case 'ebe30a1cc2742d41c7508d6f969c370f': name = '自产软件';   break;
                                    case '232658f324af246776f3520be322ff3f': name = '调整项';     break;
                                    case '0bbaf97e2250f7f8ca3defa4327635c3': name = '岸电电源';   break;
                                    case '47610efb368d8b61ee6d3c5507bde2a2': name = '测试台';     break;
                                    case 'eb31441c15d4a595446a10c4342ef981': name = '服务-6%';    break;
                                    case '3ca36386ea2a82c1c231acb0d4d14529': name = '服务-13%';   break;
                                    case '269179be3c2c8b3c128ffe54b63e0b67': name = '备件';       break;
                                    case 'd1d31ce38718f53d646d3bad0d30b74d': name = '其他';       break;
                                    default:                                  name = '';          break;
                                }
                                if (name) tempSet.add(name);   // 只保留成功匹配到的中文名
                            }

                            // 4. 转数组
                            let nameArr = [...tempSet];
                            console.log(nameArr);   // 例: ["高压变频器", "有源滤波器", "固态软启动", "维修服务"]

                            //处理表头
                            $this.model.selectStr_1690186702521_3m6iA = data[0]["input_1753770946444_03PAF"]; //项目编号 【显示被隐藏的文本】
                            $this.model.input_1690186769700_NQIMN = data[0]["input_1688608734780_FzYra"]; //项目名称;【显示被隐藏的文本】
                            //客户信息
                            $this.model.input_1761619590973_IbOMB = data[0]["input_1753771160383_nWyzU"]; //最终客户名称【显示被隐藏的文本】
                            $this.model.input_1761620910643_ju9rd = data[0]["input_1688608906477_jFYCL"]; //签约客户名称【显示被隐藏的文本】
                            $this.model.input_1761619590973_MNIfw = data[0]["input_1753770760663_1rG1x"]; //最终客户联系人
                            $this.model.input_1761619590973_CV33P = data[0]["input_1753770705078_trNYj"]; //签约客户联系人
                            $this.model.input_1761619590973_G6qDf = data[0]["input_1753770763601_aQcRL"]; //最终客户联系电话
                            $this.model.input_1761619590973_xrzsp = data[0]["input_1753770718579_5ndFj"]; //签约客户联系电话

                            //项目信息
                            $this.model.input_1761620061717_he6DO= data[0]["input_1753770946444_03PAF"]; //项目编号
                            $this.model.select_1761619590973_biiy4 = data[0]["select_1753773720879_V5l4b"]; //销售团队
                            $this.model.systemSelect_1761619590973_EK67n = data[0]["systemSelect_1761200168405_7dDJY"]; //销售负责人
                            $this.model.systemSelect_1761619590973_SvBH6 = data[0]["systemSelect_1761305069111_62IrS"]; //设计负责人
                            $this.model.systemSelect_1761619590973_JURIY = data[0]["systemSelect_1688608855355_l9XZc"]; //项目经理
                            $this.model.select_1761619590973_YyCEl = data[0]["select_1753770836763_b8on7"]; //所属行业
                            $this.model.select_1761619590973_lPS7j = nameArr; //设备类型 字典处理
                            $this.model.input_1761619590973_VMj14 = data[0]["input_1753771944911_VdhU9"]; //设备型号
                            $this.model.number_1761619590973_Qwt67 = data[0]["number_1753772044979_0mwZj"]; //数量
                            $this.model.select_1761619590973_tGuJx = data[0]["select_1760507162335_mR1iu"]; //币种
                            $this.model.input_1761619590973_FU5JE = data[0]["input_1758703429069_praGC"]; //合同质保条款
                            $this.model.select_1761619590973_OTV1v = data[0]["select_1753772231534_wLP30"]; //发货方式

                            //时间特殊处理
                            $this.model.datepicker_1761619590973_SUCgx = data[0]["datepicker_1688608834665_f8cZm"]; //立项时间
                            $this.model.datepicker_1761619590973_WgfiB = data[0]["datepicker_1753771875511_JZrk0"]; //项目交货期

                            //变更任务信息
                            $this.model.select_1690186777289_NxOJa = data[0]["select_1688608801603_AQrGK"] || ''; //项目状态
                            $this.model.input_1761619590973_VMj14 = data[0]["input_1753771944911_VdhU9"] || ''; //设备型号
                            $this.model.input_1761619590973_p0z6Q = data[0]["input_1690184649174_VbQou"] || ''; //项目地址
                            $this.model.textarea_1761619590973_PV7dO = data[0]["textarea_1753772355571_qpoZy"] || ''; //项目描述
                            $this.model.textarea_1761619590973_3cmqQ = data[0]["textarea_1688609935588_Rztic"] || ''; //付款条件
                            $this.model.textarea_1761619590972_TM6Ql = data[0]["textarea_1753772205602_rgWlA"] || ''; //售后服务 没有

                            // 表体存在
                            for (let j = 0; j < data.length; j++) {
                                if(data[j]["body_id"] != null && data[j]["body_id"] !== "") {
                                    //处理表体; 构造 一条表体数据，push 进表格。
                                    $this.model["table_1761621684298_7OBB8"].push({
                                        body_id:$this.$util.uuid(),
                                        create_date:$this.$util.getFormatDate(),
                                        //index_id会有问题
                                        index_id:$this.model["table_1761621684298_7OBB8"].length>0?$this.model["table_1761621684298_7OBB8"][$this.model["table_1761621684298_7OBB8"].length-1].index_id+1:1,
                                        table_body_id:data[j]["body_id"],
                                        //项目状态变更 = 项目立项 【数据赋值逻辑】
                                        body_1761621788838_DDwaS: data[j]["body_1688610447952_3wkmh"],//人员名称
                                        body_1761621804163_wwk07: data[j]["body_1688610485722_RuEWp"],//项目角色
                                        body_1761621816327_yXxna: data[j]["body_1688610524215_DAP8D"],//状态
                                        body_1761621999355_Xbb9y: data[j]["body_1688610546451_EAZeW"],//备注
                                        body_1764059079702_lRu1W: data[j]["body_1761894492527_Zn5J5"],//项目编号
                                        body_1764060250659_flcpx: "修改"//数据状态
                                    });
                                }
                            }
                        }
                    });
                }
            }
        }
    }
}

main();




let num = $this.model.table_1761621684298_7OBB8.length;
let headData = $this.model; // 表头数据
if (num > 0) {
    for (let i = 0; i < num; i++) {
        // let id = $this.$util.uuid(); // 表单id
        let bodyData = $this.model.table_1761621684298_7OBB8[i]; // 表体数据
        // ⭐ 只处理 table_body_id 为 null 的行
        if (bodyData.table_body_id !== undefined) continue;
        let saveObj  ={
            //通用字段
            "bill_id": $this.model.bill_id,
            "body_id":bodyData["body_id"],//表体id
            "index_id":0,
            "create_date":bodyData["create_date"],
            "table_body_id":bodyData["table_body_id"],
            //查看创建日期是否受牵连
            "create_date":headData.create_date,
            //项目状态变更表体下推到项目立项表体
            "body_1688610447952_3wkmh":bodyData["body_1761621788838_DDwaS"],//人员名称
            "body_1688610447952_3wkmh_ID":bodyData["body_1761621788838_DDwaS_ID"],//人员名称
            "body_1688610524215_DAP8D":bodyData["body_1761621816327_yXxna"],//状态
            "body_1688610546451_EAZeW":bodyData["body_1761621999355_Xbb9y"],//备注
            "body_1688610485722_RuEWp":bodyData["body_1761621804163_wwk07"],//项目角色
            "body_1764059079702_lRu1W":bodyData["body_1761894492527_Zn5J5"],//项目编号
            "body_1764060250659_flcpx":"新增"//数据状态
        }
        let formData = new FormData()
        formData.append('obj', JSON.stringify(saveObj))
        $this.$http.post("/formsBusiness/getZtbgByBoduId/", formData).then(res => {
            let data=res.data.data
            console.log(data)
        }).catch(e => {
            $this.$message.error(e.message);
        });
    }
}